
package com.wlsk.license.service.zpff;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum RtabResultCode {

    TOKEN_ERROR("101", "Token验证失败"),

    SM4_ERROR("102", "SM4验证失败"),

    SUCCESS("200", "服务器已成功处理了请求"),

    REQUEST_ERROR("400", "服务器不理解请求的语法"),

    REJECT_ERROR("403", "服务器拒绝请求"),

    NOT_FOUND("404", "服务器找不到请求的页面"),

    SERVICE_ERROR("500", "服务器遭遇异常阻止了当前请求的执行"),

    FORMAT_ERROR("700", "格式校验失败"),

    OTHER_ERROR("900", "其他错误");

    private static final Map<String, RtabResultCode> codeMap = new HashMap<>();

    static {
        for (RtabResultCode s : EnumSet.allOf(RtabResultCode.class)) {
            codeMap.put(s.code(), s);
        }
    }

    private String resultCode;

    private String resultDesc;

    RtabResultCode(String resultCode, String resultDesc) {
        this.resultCode = resultCode;
        this.resultDesc = resultDesc;
    }

    public static RtabResultCode valueToCode(String codeValue) {
        RtabResultCode code = codeMap.get(codeValue);
        if (code == null) {
            code = OTHER_ERROR;
        }
        return code;
    }

    public String code() {
        return resultCode;
    }

    public String desc() {
        return resultDesc;
    }

}
